﻿<%@ Page Title="" Language="VB" MasterPageFile="~/App/Master/App.master" AutoEventWireup="false" CodeFile="UserAccounts.aspx.vb" Inherits="App_UserAccounts" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CphHead" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CphMainContent" runat="Server">

    <script type="text/javascript" src="http://visjs.org/dist/vis.js"></script>
    <link href="http://visjs.org/dist/vis.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">


        $(function () {

            $("#BtnAddAccount").on("click", function () {
                event.preventDefault();
                if (!var_server.limitaccount) {
                    add_account('twitter');
                } else {
                    show_upgrade_plain();
                }
            });


            $("#BtnPayPal").on("click", function () {
                add_account('paypal');
            });


            $("#BtnAddAccount2").on("click", function () {

                $.oauthpopup({
                    path: 'useraccounts.aspx?network=facebook',
                    callback: function () {
                        window.top.location.href = '/app#UserAccount';
                        window.top.location.reload();
                    },
                    windowName: "facebook",
                    windowOptions: "location=0,status=0,width=800,height=600"
                });


            });

            $("#BtnAddAccount3").on("click", function () {

                $.oauthpopup({
                    path: 'useraccounts.aspx?network=google',
                    callback: function () {
                        window.top.location.href = '/app#UserAccount';
                        window.top.location.reload();
                    },
                    windowName: "google",
                    windowOptions: "location=0,status=0,width=800,height=600"
                });


            });

            $("#BtnAddAccount4").on("click", function () {

                $.oauthpopup({
                    path: 'useraccounts.aspx?network=linkedin',
                    callback: function () {
                        window.top.location.href = '/app#UserAccount';
                        window.top.location.reload();
                    },
                    windowName: "linkedin",
                    windowOptions: "location=0,status=0,width=800,height=600"
                });


            });

            $("#BtnAddAccount5").on("click", function () {

                $.oauthpopup({
                    path: 'useraccounts.aspx?network=instagram',
                    callback: function () {
                        window.top.location.href = '/app#UserAccount';
                        window.top.location.reload();
                    },
                    windowName: "instagram",
                    windowOptions: "location=0,status=0,width=800,height=600"
                });


            });

            $("#BtnAddAccount6").on("click", function () {

                $.oauthpopup({
                    path: 'useraccounts.aspx?network=buffer',
                    callback: function () {
                        window.top.location.href = '/app#buffer';
                        window.top.location.reload();
                    },
                    windowName: "buffer",
                    windowOptions: "location=0,status=0,width=800,height=600"
                });


            });


            draw();
        });



        function add_account(n) {



            $.oauthpopup({
                path: '/useraccounts?network=' + n,
                callback: function () {
                    //window.top.location.href = '/app#UserAccount';
                    top.location.reload();
                },
                windowName: n,
                windowOptions: "location=0,status=0,width=800,height=600"
            });
        }

        function paypal(t) {

            $.oauthpopup({
                path: 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=express-checkout&token=' + t,
                callback: function () {
                    window.top.location.href = '/app#UserAccount';
                    window.top.location.reload();
                },
                windowName: 'dd',
                windowOptions: "location=0,status=0,width=800,height=600"
            });
        }


        var DIR = 'img/soft-scraps-icons/';

        var nodes = null;
        var edges = null;
        var network = null;

        function draw(o) {
            // create people
            //nodes = [
            //  { id: 1, label: 'Algie', image: DIR + 'Smiley-Angry-icon.png', shape: 'image' },
            //  { id: 2, label: 'Alston', image: DIR + 'Smiley-Grin-icon.png', shape: 'image' },
            //  { id: 3, label: 'Barney', image: DIR + 'User-Administrator-Blue-icon.png', shape: 'image' },
            //  { id: 4, label: 'Coley', image: DIR + 'User-Administrator-Green-icon.png', shape: 'image' },
            //  { id: 5, label: 'Grant', image: DIR + 'User-Coat-Blue-icon.png', shape: 'image' },
            //  { id: 6, label: 'Langdon', image: DIR + 'User-Coat-Green-icon.png', shape: 'image' },
            //  { id: 7, label: 'Lee', image: DIR + 'User-Coat-Red-icon.png', shape: 'image' },
            //  { id: 8, label: 'Merlin', image: DIR + 'User-Executive-Green-icon.png', shape: 'image' },
            //  { id: 9, label: 'Mick', image: DIR + 'User-Preppy-Blue-icon.png', shape: 'image' },
            //  { id: 10, label: 'Tod', image: DIR + 'User-Preppy-Red-icon.png', shape: 'image' }
            //];

            // create connections
            var color = '#BFBFBF';
            //edges = [
            //  { from: 2, to: 8, value: 3, label: 3, color: color },
            //  { from: 2, to: 9, value: 5, label: 5, color: color },
            //  { from: 2, to: 10, value: 1, label: 1, color: color },
            //  { from: 4, to: 6, value: 8, label: 8, color: color },
            //  { from: 5, to: 7, value: 2, label: 2, color: color },
            //  { from: 4, to: 5, value: 1, label: 1, color: color },
            //  { from: 9, to: 10, value: 2, label: 2, color: color },
            //  { from: 2, to: 3, value: 6, label: 6, color: color },
            //  { from: 3, to: 9, value: 4, label: 4, color: color },
            //  { from: 5, to: 3, value: 1, label: 1, color: color },
            //  { from: 2, to: 7, value: 4, label: 4, color: color }
            //];

            // create a network
            var container = document.getElementById('mynetwork');
            var data = {
                nodes: o.nodes,
                edges: o.edges
            };
            var options = {
                stabilize: false,
                configurePhysics: false,
                smoothCurves: false,
                physics: {
                    barnesHut: {
                        enabled: true,
                        gravitationalConstant: -20000,
                        centralGravity: 0,
                        springLength: 150,
                        springConstant: 0.010
                    }
                },
                nodes: {
                    widthMin: 40,
                    widthMax:80,
                    fontSize: 13,
                    borderWidth:3,
                    fontColor: '#333333',
                    color: {
                        background: '#cccccc',
                        border: '#29AAE3'
                        
                    }


                },
                edges: {
                    color: {
                        color:'#cccccc',
                        highlight: '#C2272D'
                    },
                    inheritColor: false
                },
                tooltip: {
                    delay: 200,
                    fontSize: 12,
                    color: {
                        background: "#fff"
                    }
                }


            };
            network = new vis.Network(container, data, options);
        }
        //var conf = false;
        //function openconfirm(e) {

        //    if (!conf) {
        //        $("#dialog-confirm").dialog({
        //            height: 200,
        //            width: 350,
        //            modal: true,
        //            buttons: {
        //                "Ok": function () {
        //                    $(this).dialog("close");
        //                    conf = true;
        //                    //alert(e);
        //                    //__doPostBack('ctl00$CphMainContent$ListAccount$ctrl0$ctl03', '');
        //                    e.click();
        //                },
        //                "cancel": function () {
        //                    $(this).dialog("close");
        //                }

        //            }
        //        });
        //        return false

        //    } else {
        //        conf = false;
        //        return true

        //    }

        //}

    </script>

    <%--    <div id="dialog-confirm" style="display: none;" title="Delete item?">
        <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
    </div>--%>

    <!-- box 1 -->
    <div class="row-fluid">
        <!-- opzioni -->
        <div class="twitter-accounts">

            <!-- contenuti -->
            <div class="well-twitter-accounts">
                <div class="account-plan-text">
                    Your plan:<div class="account-plan-type">Basic</div>
                </div>
                <div class="account-manage">
                    <div class="account-manage-text">Manage</div>
                    <div class="account-manage-num"><%=CurrUser.Plan.Account_Per_User%></div>
                    <div class="account-manage-tweet">Twitter account</div>
                </div>
                <div class="account-analyze">
                    <div class="account-analyze-text">Analyze</div>
                    <div class="account-analyze-num"><%=CurrUser.Plan.Follower_Analysis_Per_User%></div>
                    <div class="account-analyze-followers">followers</div>
                </div>
                <div class="account-queries">
                    <div class="account-queries-num"><%=CurrUser.Plan.Query_Per_User%></div>
                    <div class="account-queries-text">hashtag queries</div>
                </div>
                <div class="account-listening">
                    <div class="account-listening-num"><%=CurrUser.Plan.Listen_Per_Account%></div>
                    <div class="account-listening-text">hashtag listening for acc</div>
                </div>
                <div class="account-listening">
                    <div class="account-listening-num"><%=CurrUser.Plan.Auto_Follower_Per_Account%></div>
                    <div class="account-listening-text">autofoll for acc</div>
                </div>

                <div class="expandable-image"></div>
            </div>
            <asp:LinkButton runat="server" ID="BtnAddAccount">
                <div class="well-add-accounts">
                    <div class="add-accounts">
                        add Twitter account
                    </div>

                    <div class="expandable-image-add"></div>
                </div>
            </asp:LinkButton>
            <a class=" link_to" href="/app/billing.aspx">
                <div class="well-upgrade-accounts">
                    <div class="upgrade-accounts">
                        upgrade
                    </div>

                </div>
            </a>
            <!-- fine contenuti -->
        </div>
    </div>

    <!-- box 2 -->
    <div class="row-fluid">
        <!-- account -->
        <asp:UpdatePanel runat="server" ID="UpdAccount" UpdateMode="Conditional" class="your-accounts">
            <ContentTemplate>
                <!-- titolo -->
                <div class="top-bar">
                    your Twitter accounts
                <div>
                    <a href="#" class="a-icona7 tooltip" title="Nel titolo il testo toltip"></a>
                </div>
                </div>
                <!-- contenuto -->
                <div class="well-your-accounts">
                    <div class="your-accounts-head">
                        <div class="your-accounts-head-name">
                            account name
                        </div>
                        <div class="your-accounts-head-avatar">
                            avatar
                        </div>
                        <div class="your-accounts-head-description">
                            description
                        </div>
                        <div class="your-accounts-head-location">
                            location
                        </div>
                        <div class="your-accounts-head-following">
                            following
                        </div>
                        <div class="your-accounts-head-follower">
                            followers
                        </div>
                        <div class="your-accounts-head-advanced">
                            advanced analysis
                        </div>
                        <div class="your-accounts-head-close">
                        </div>
                    </div>

                    <asp:ListView runat="server" ID="ListAccount" ClientIDMode="Predictable">
                        <ItemTemplate>
                            <div class="your-accounts-row">
                                <div class="your-accounts-row-name">
                                    <%# eval("fullname") %>
                                    <div class="your-accounts-row-link">@<%# Eval("username")%></div>
                                </div>
                                <div class="your-accounts-row-avatar">
                                    <img src="<%# eval("avatar") %>" style="width: 40px;" />
                                </div>
                                <div class="your-accounts-row-description">

                                    <div class="schedule-row-next-body">
                                        <%# Eval("description")%>
                                    </div>
                                </div>
                                <div class="your-accounts-row-location">
                                    <%# Eval("location")%>
                                </div>
                                <div class="your-accounts-row-following">
                                    <%# UI.Print.Num0(Eval("friend_count"))%>
                                </div>
                                <div class="your-accounts-row-followers">
                                    <%# UI.Print.Num0(Eval("follower_count"))%>
                                </div>
                                <div class="your-accounts-row-advanced">
                                    <asp:LinkButton runat="server" CommandName="ADD_ANALISYS" CssClass="a-icona-analysis-s" Visible='<%# Not CBool (Eval("analysis_followers"))%>' />
                                    <asp:LinkButton runat="server" CommandName="REMOVE_ANALISYS" CssClass="a-icona-analysis" Visible='<%# Eval("analysis_followers")%>' />
                                    <asp:Label runat="server" ForeColor="Red" Visible='<%# Eval("analysis_followers_limit") > 0 %>' Text='<%# Eval("analysis_followers_limit")%>'></asp:Label>

                                </div>
                                <div class="your-accounts-row-chiudi">

                                    <div class="schedule-chiudi">
                                        <asp:Button runat="server" CommandName="DELETE_ACCOUNT" OnClientClick="return openconfirm(this);" CssClass="a-icona-chiudi"></asp:Button>
                                    </div>

                                </div>
                            </div>
                        </ItemTemplate>
                    </asp:ListView>
                </div>

                <div class="your-accounts-footer">
                    <App:DataPager runat="server" Controlid="ListAccount" PageSize="10" OnPageChanged="SetListAccount" />
                </div>

            </ContentTemplate>
        </asp:UpdatePanel>

<%--        <div id="mynetwork" style="width: 100%; height: 900px; border: 1px solid lightgray; background: #F3F3F3;"></div>--%>


    </div>

    <%--    <asp:Button runat="server" ID="bbbb" Text="attiva" />--%>

    <%--    <asp:Panel runat ="server" Visible ="false">

<hr />
    piano attuale:
    <br />
    piano:    <%= Me.CurrUser.Plan.Id%><br />
    inizio piano:    <%= Me.CurrUser.CurrUserPlan.Plan_Begin_Date%><br />
    scadenza piano:    <%= Me.CurrUser.CurrUserPlan.Plan_Expire_Date%><br />
    
    <hr />
promo attuale:
    <br />
    <% If CurrUser.Promo IsNot Nothing Then%>
    promo:    <%= Me.CurrUser.Promo.Id%><br />
    inizio promo:    <%= Me.CurrUser.CurrUserpromo.Promo_Begin_Date%><br />
    scadenza promo:    <%= Me.CurrUser.CurrUserpromo.Promo_Expire_Date%><br />
    <%End If%>

    <hr />
sisutazione attuale:
        <br />
costo mese : <%= CurrUser.GetCurrPrice(1)%><br />
costo anno : <%= CurrUser.GetCurrPrice(12)%><br />

<hr />
piano 2
costo mese : <%= piano.Getprice(1)%><br />
costo anno : <%= piano.Getprice(12)%><br />
    
con promo 
costo questo mese : <%= oo.Getprice(1)%><br />
costo anno : <%= oo.Getprice(12)%><br />

<hr />
        </asp:Panel>--%>
    <asp:Panel runat="server" ID="PnlSocialAcc">
        <input type="button" id="BtnPayPal" value="PAGA" />
        <input type="button" id="BtnAddAccount2" value="Add FACEBBOK" />
        <input type="button" id="BtnAddAccount3" value="Add GOOGLE" />
        <input type="button" id="BtnAddAccount4" value="Add LINKEDIN" />
        <input type="button" id="BtnAddAccount5" value="Add INSTAGRAM" />
        <input type="button" id="BtnAddAccount6" value="Add BUFFER" />
    </asp:Panel>



</asp:Content>

